var $ = require('jquery');
module.exports = {
    get: function (url){
        var defer = $.Deferred();
        $.ajax({
  			url: url,
  			method: 'GET',
  			contentType: 'application/json;charset=utf-8',
            success: defer.resolve,
            error: defer.reject
  		});

        return defer.done().promise();
  	},
    post: function (url, data, callback){
        var defer = $.Deferred();
        $.ajax({
  			url: url,
  			method: 'POST',
  			contentType: 'application/json;charset=utf-8',
  			data: JSON.stringify(data),
            success: defer.resolve,
            error: defer.reject
  		});

        return defer.done(callback).promise();
  	},
    jsonp: function (url, data){
        var defer = $.Deferred();
        $.ajax({
            url: url,
            data: data,
            dataType: "jsonp",
            success: defer.resolve,
            error: defer.reject
        });

        return defer.done().promise();
    }
}
